package cn.iocoder.yudao.module.handguard.controller.app.applicationrecord;

import cn.iocoder.yudao.module.handguard.controller.admin.order.vo.MemberUserBaseVO;
import cn.iocoder.yudao.module.handguard.dal.dataobject.product.ProductDO;
import cn.iocoder.yudao.module.handguard.enums.OrderFlowEnum;
import cn.iocoder.yudao.module.handguard.enums.OrderStatusEnum;
import cn.iocoder.yudao.module.handguard.service.product.ProductService;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;

import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;

import cn.iocoder.yudao.module.handguard.controller.app.applicationrecord.vo.*;
import cn.iocoder.yudao.module.handguard.dal.dataobject.applicationrecord.ApplicationRecordDO;
import cn.iocoder.yudao.module.handguard.convert.applicationrecord.ApplicationRecordConvert;
import cn.iocoder.yudao.module.handguard.service.applicationrecord.ApplicationRecordService;

@Tag(name = "小程序 - 用户申请贷款表（申请通过创建订单）")
@RestController
@RequestMapping("/hutai/application-record")
@Validated
public class ApplicationRecordController {

    @Resource
    private ApplicationRecordService applicationRecordService;

    @Resource
    private ProductService productService;

//    @PostMapping("/create")
//    @Operation(summary = "创建用户申请贷款表（申请通过创建订单）")
//    @PreAuthorize("@ss.hasPermission('hutai:application-record:create')")
//    public CommonResult<Long> createApplicationRecord(@Valid @RequestBody ApplicationRecordCreateReqVO createReqVO) {
//        return success(applicationRecordService.createApplicationRecord(createReqVO));
//    }

//    @PutMapping("/update")
//    @Operation(summary = "更新用户申请贷款表（申请通过创建订单）")
//    @PreAuthorize("@ss.hasPermission('hutai:application-record:update')")
//    public CommonResult<Boolean> updateApplicationRecord(@Valid @RequestBody ApplicationRecordUpdateReqVO updateReqVO) {
//        applicationRecordService.updateApplicationRecord(updateReqVO);
//        return success(true);
//    }

//    @DeleteMapping("/delete")
//    @Operation(summary = "删除用户申请贷款表（申请通过创建订单）")
//    @Parameter(name = "id", description = "编号", required = true)
//    @PreAuthorize("@ss.hasPermission('hutai:application-record:delete')")
//    public CommonResult<Boolean> deleteApplicationRecord(@RequestParam("id") Long id) {
//        applicationRecordService.deleteApplicationRecord(id);
//        return success(true);
//    }

//    @GetMapping("/get")
//    @Operation(summary = "获得用户申请贷款表（申请通过创建订单）")
//    @Parameter(name = "id", description = "编号", required = true, example = "1024")
//    @PreAuthorize("@ss.hasPermission('hutai:application-record:query')")
//    public CommonResult<ApplicationRecordRespVO> getApplicationRecord(@RequestParam("id") Long id) {
//        ApplicationRecordDO applicationRecord = applicationRecordService.getApplicationRecord(id);
//        return success(ApplicationRecordConvert.INSTANCE.convert(applicationRecord));
//    }

    @GetMapping("/list")
    @Operation(summary = "我的-获得用户申请贷款表（申请通过创建订单）列表")
    @Parameter(name = "status", description = "状态：1申请中，2已完成", required = true, example = "1024")
    public CommonResult<List<ApplicationRecordRespVO>> getApplicationRecordListByUserId(@RequestParam("status") String status) {
        //当前用户id
        Long userId = getLoginUser().getId();
        List<ApplicationRecordRespVO> list = applicationRecordService.getApplicationRecordListByUserId(userId,status);
        return success(list);
    }


//    @GetMapping("/getOrderUserInfo")
//    @Operation(summary = "用户贷款记录")
//    public CommonResult<List<ApplicationRecordRespVO>> getOrderUserInfo(Long id) {
//        List<ApplicationRecordRespVO> respVOList = applicationRecordService.getApplicationRecordList(id);
//        return success(respVOList);
//    }

//    @GetMapping("/page")
//    @Operation(summary = "获得用户申请贷款表（申请通过创建订单）分页")
//    @PreAuthorize("@ss.hasPermission('hutai:application-record:query')")
//    public CommonResult<PageResult<ApplicationRecordRespVO>> getApplicationRecordPage(@Valid ApplicationRecordPageReqVO pageVO) {
//        PageResult<ApplicationRecordDO> pageResult = applicationRecordService.getApplicationRecordPage(pageVO);
//        return success(ApplicationRecordConvert.INSTANCE.convertPage(pageResult));
//    }



}
